package com.example.blew.omp.system.model.converter;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.example.blew.omp.system.model.form.FileForm;
import com.example.blew.omp.system.model.po.File;

import java.util.ArrayList;
import java.util.List;

public class FileConverter {
    public static File converterToPoByFrom(FileForm source){
        if (source == null) {
            return null;
        }
        File target = new File();
        BeanUtil.copyProperties(source, target);
        return target;

    }

    public static List<File> converterToPoByFrom(List<FileForm> sources){
        if (CollUtil.isEmpty(sources)) {
            return null;
        }
        List<File> result=new ArrayList<>();
        for(FileForm source: sources){
            File target = new File();
            BeanUtil.copyProperties(source, target);
            result.add(target);
        }
        return result;

    }
}
